home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWToolbx / Sources / SLMixOS.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  3.8 KB  |  146 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLMixOS.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef SLMIXCOS_H
  13. #include "SLMixOS.h"
  14. #endif
  15.  
  16. #ifndef FWFXMATH_H
  17. #include "FWFxMath.h"
  18. #endif
  19.  
  20. #ifndef FWPOINT_H
  21. #include "FWPoint.h"
  22. #endif
  23.  
  24. #ifndef FWRECT_H
  25. #include "FWRect.h"
  26. #endif
  27.  
  28. //========================================================================================
  29. //    Runtime Informations
  30. //========================================================================================
  31.  
  32. #ifdef FW_BUILD_MAC    
  33. #pragma segment fwtoolbx
  34. #endif
  35.  
  36. //========================================================================================
  37. //    Mix OS Utilities
  38. //========================================================================================
  39.  
  40. //----------------------------------------------------------------------------------------
  41. // ::CenterRectOnScreen
  42. //----------------------------------------------------------------------------------------
  43.  
  44. FW_PlatformError SL_API FW_CenterRectOnScreen(FW_SRect& aRect, FW_Boolean horizontally, FW_Boolean vertically, FW_Boolean forDialog)
  45. {
  46.     // No try block necessary - Do not throw
  47.  
  48. #ifdef FW_BUILD_MAC
  49.     FW_CPlatformRect srcRect = *(FW_CRect*)&aRect;
  50.     
  51.     short newSize = 0;
  52.     FW_CPlatformPoint rectSize, screenSize;
  53.  
  54.     ::SetPt(&rectSize, srcRect.right - srcRect.left, srcRect.bottom - srcRect.top);
  55.     ::SetPt(&screenSize, FW_QDGlobals.screenBits.bounds.right - FW_QDGlobals.screenBits.bounds.left,
  56.                         FW_QDGlobals.screenBits.bounds.bottom - FW_QDGlobals.screenBits.bounds.top);
  57.     screenSize.v -= GetMBarHeight();
  58.  
  59.     // Calculate screen size minus menu bar 
  60.     if (horizontally)
  61.         srcRect.left = (screenSize.h - rectSize.h) / 2;
  62.     if (vertically)
  63.         if (forDialog)
  64.         {
  65.             newSize = (screenSize.v - rectSize.v) / 5;
  66.             srcRect.top = (short)(FW_Maximum(newSize, (short) 10) + GetMBarHeight());
  67.         }
  68.         else
  69.             srcRect.top = (screenSize.v - rectSize.v) / 2;
  70.     
  71.     srcRect.bottom = srcRect.top + rectSize.v;
  72.     srcRect.right = srcRect.left + rectSize.h;
  73.  
  74.     *(FW_CRect*)&aRect = srcRect;
  75. #endif
  76.  
  77. #ifdef FW_BUILD_WIN
  78. FW_UNUSED(aRect);
  79. FW_UNUSED(horizontally);
  80. FW_UNUSED(vertically);
  81. FW_UNUSED(forDialog);
  82.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  83. #endif
  84.     
  85.     return FW_xNoError;
  86. }
  87.  
  88. //----------------------------------------------------------------------------------------
  89. // FW_GetMainScreenBounds
  90. //----------------------------------------------------------------------------------------
  91.  
  92. FW_PlatformError SL_API FW_GetMainScreenBounds(FW_SRect& bounds)
  93. {
  94.     // No try block necessary - Do not throw
  95.  
  96. #ifdef FW_BUILD_MAC
  97.     FW_CPlatformRect scr(0, 
  98.                         LMGetMBarHeight(),
  99.                            FW_QDGlobals.screenBits.bounds.right,
  100.                            LMGetMBarHeight() + FW_QDGlobals.screenBits.bounds.bottom);
  101. #endif
  102.     
  103. #ifdef FW_BUILD_WIN
  104.     FW_CPlatformRect scr;
  105.     ::GetWindowRect(::GetDesktopWindow(), &scr);
  106. #endif
  107.  
  108.     *(FW_CRect*)&bounds = scr;
  109.     
  110.     return FW_xNoError;
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. // ::FW_Beep
  115. //----------------------------------------------------------------------------------------
  116.  
  117. void SL_API FW_Beep()
  118. {
  119.     // No try block necessary - Do not throw
  120.  
  121. #ifdef FW_BUILD_MAC
  122.     ::SysBeep(10);
  123. #endif
  124. #ifdef FW_BUILD_WIN
  125.     ::MessageBeep(MB_OK);
  126. #endif
  127. }
  128.  
  129. //----------------------------------------------------------------------------------------
  130. // ::FW_GetTickCount
  131. //----------------------------------------------------------------------------------------
  132.  
  133. unsigned long SL_API FW_GetTickCount()
  134. {
  135.     // No try block necessary - Do not throw
  136.  
  137. #ifdef FW_BUILD_MAC
  138.     return ::TickCount();
  139. #endif
  140. #ifdef FW_BUILD_WIN
  141.     return ::GetTickCount();
  142. #endif
  143. }
  144.  
  145.  
  146.